package com.lhz.common.constant;

import lombok.Getter;

/**
 * @Author: LiHuaZhi
 * @Date: 2021/8/30 21:39
 * @Version: 1.0
 **/
@Getter
public enum ResponseState {
    FAIL("失败", 500),
    SUCCESS("成功", 200),
    EXCEPTION("服务器异常", 400),
    TOKEN_ERROR("请先登录", 401),
    NOT_AUTH("权限不足!", 403),
    NOT_ROLE("暂未分配角色,无法登录!", 201),
    NOT_PERMISSION("暂未分配操作权限,无法登录!", 201),
    NOT_RANG("暂未分配数据权限,无法登录!", 201),
    DEVICE_REPEAT("设备已存在请检查序列号", 202),
    DEVICE_TYPE_ERROR("设备类型错误", 203),
    ACCOUNT_UNDEFINED("用户不存在", 201),
    ACCOUNT_DEFINED("账户已存在", 202),
    PASS_UNDEFINED("密码错误", 201),
    VALID_FAIL("参数格式不合法", 203),
    REPEAT_ADD("名称重复", 204),
    HAS_CHILD_MENU("存在子菜单,不允许删除", 205),
    MENU_EXIST("菜单已分配,不允许删除", 206),
    FILE_NOT_EMPTY("文件不能为空", 207),
    FILE_CONTENT_NOT_EMPTY("文件内容不能为空", 208),
    FILE_NAME_NOT_EMPTY("文件名为空", 209),
    FILE_UPLOAD_FALL("上传文件失败", 210),
    NO_PERMISSION("权限不足", 402),

    SERVER_LIMITER("服务器拥挤,请稍后再试!", 5001), SERVER_LIMITER_ERROR("服务器挤爆了,请稍后再试!", 5002);

    private final String name;
    private final int code;

    ResponseState(String name, int code) {
        this.name = name;
        this.code = code;
    }

    public static String getName(int code) {
        ResponseState[] var1 = values();
        int var2 = var1.length;

        for (ResponseState c : var1) {
            if (c.getCode() == code) {
                return c.name;
            }
        }

        return null;
    }

    public static ResponseState getResponseSate(String enumName) {
        ResponseState[] var1 = values();
        for (ResponseState c : var1) {
            if (c.name().equals(enumName)) {
                return c;
            }
        }

        return null;
    }

}
